#ifndef GST_MOMAPROPERTYVALUE_H
#define GST_MOMAPROPERTYVALUE_H

#include <buildspec.h>
#include <config.h>	
#include <Geometry/IGeometry.h>
#include <Client/ClientUtils/Network/NetworkInterfaceStructs.h>
#include <Client/ClientUtils/MoMaPropertyDesc.h>

#include <boost/shared_ptr.hpp>
#include <boost/variant.hpp>

#include <string>
#include <vector>

using GST::ClientUtils::MoMaPropertyDesc;
using GST::ClientUtils::MoMaPropertyDescPtr;

// since older compiler don't have this defined
#ifndef FLT_DIG
    #define FLT_DIG __FLT_DIG__
#endif
#ifndef DBL_DIG
#define DBL_DIG __DBL_DIG__
#endif

namespace GST {
	namespace ClientUtils {

class GST_API_EXPORT MoMaPropertyValue
	: public boost::static_visitor<std::string>
{
public:
	typedef boost::variant<bool, int, long, float, double, std::string> PVALUE;
	template <typename T> 
	std::string operator()( T & t) const
	{
		std::stringstream str;
		str << t;
		return str.str();
	}
	std::string operator()( double & t) const
	{
		std::stringstream str;
		str << std::setprecision(DBL_DIG) << t;
		return str.str();
	}
	std::string operator()( float & t) const
	{
		std::stringstream str;
		str << std::setprecision(FLT_DIG) << t;
		return str.str();
	}
private:
	PVALUE value; 
	MoMaPropertyDescPtr desc;
	LinkedElementPtr linkedElement;
public:
	MoMaPropertyValue();
	MoMaPropertyValue(const MoMaPropertyValue& other);
	MoMaPropertyValue(PVALUE _value, MoMaPropertyDescPtr _desc, LinkedElementPtr _element);
	PVALUE getValue() const;
	TableAttributeDesc::DType getDType() const;
	MoMaPropertyDescPtr getMoMaPropertyDesc() const;
	LinkedElementPtr getLinkedElement() const;
	void setValue(PVALUE newvalue);
	MoMaPropertyDesc::PROPERTYID getDescId() const;
	LinkAdjacency::LinkId getLinkedElementId() const;
	~MoMaPropertyValue();
};

typedef boost::shared_ptr<MoMaPropertyValue> MoMaPropertyValuePtr;
typedef std::vector<MoMaPropertyValuePtr> MoMaPropertyValueList;
typedef boost::shared_ptr<MoMaPropertyValueList> MoMaPropertyValueListPtr;

}//namespace ClientUtils 
}// namespace GST

#endif // GST_MOMAPROPERTYVALUE_H
